const billPointData = [{value:0, text:"不含票", selected:true}, {value:-1, text:"普票1%"}, {value:-3, text:"普票3%"}, {value:-6, text:"普票6%"}, {value:1, text:"专票1%"}, {value:3, text:"专票3%"}, {value:6, text:"专票6%"}];
const billPointDataAll = [{value:"ALL", text:"全部", selected:true}, {value:0, text:"不含票"}, {value:-1, text:"普票1%"}, {value:-3, text:"普票3%"}, {value:-6, text:"普票6%"}, {value:1, text:"专票1%"}, {value:3, text:"专票3%"}, {value:6, text:"专票6%"}];

/**
 * 通用信息格式化----开始
 */
//发票税点
const billPointFormatter = function (value) {
    if (value < 0) {
        return '<span class="label label-success radius">普</span>' + (0-value) + '%';
    } else if (value === 0) {
        return '<span class="label label-default radius">不含票</span>';
    } else {
        return '<span class="label label-danger radius">专</span>' + value + '%';
    }
};
//创建人
const createUserIdFormatter = function (value, row) {
    return row.createUserName;
};
//审核人
const auditUserIdFormatter = function (value, row) {
    return row.auditUserName;
};
//支付人
const payUserIdFormatter = function (value, row) {
    return row.payUserName;
};
//日期
const dateFormatter = function (value) {
    return value ? dates("Y-m-d", value) : "";
};
//时间
const timeFormatter = function (value) {
    return value ? dates("H:i:s", value) : "";
};
//日期时间
const dateTimeFormatter = function (value) {
    return value ? dates("Y-m-d H:i:s", value) : "";
};
//备注
const remarkFormatter = function (value) {
    return value ? '<span data-toggle="tooltip" data-placement="bottom" title="'+value+'">'+value+'</span>' : '';
};

/**
 * 岗位信息格式化----开始
 */
const roleDepartmentFormatter = function (value) {
    switch (value) {
        case 1:
            return '管理部';
        case 2:
            return '媒介部';
        case 3:
            return '销售部';
        case 4:
            return '财务部';
    }
};

/**
 * 员工信息格式化----开始
 */
const userStatusFormatter = function (value) {
    switch (value) {
        case 1:
            return '<span class="label label-success radius">启用</span>';
        case 2:
            return '<span class="label label-default radius">停用</span>';
    }
};
/*员工信息格式化----结束*/

/*消息信息格式化----开始*/
//消息状态
const message_status_data_all = [{value:1, text:"未读"}, {value:2, text:"已读"}];
const message_status_formatter = function (value) {
    switch (value) {
        case 1:
            return '<span class="label label-danger radius">未读</span>';
        case 2:
            return '<span class="label label-success radius">已读</span>';
    }
};
//发送时间
const message_send_date_formatter = function (value) {
    return value == null ? "" : dates("Y-m-d H:i:s", value);
};
//消息内容
const message_content_formatter = function (value) {
    return value ? '<span data-toggle="tooltip" data-placement="bottom" title="'+value+'">'+value+'</span>' : '';
};
/*消息信息格式化----结束*/

/*客户信息格式化----开始*/
const customerStatusData = [{value:1, text:"启用", selected:true}, {value:2, text:"停用"}];
const customerStatusDataAll = [{value:"ALL", text:"全部", selected:true}, {value:1, text:"启用"}, {value:2, text:"停用"}];
//客户状态
const customer_status_formatter = function (value, row) {
    switch (value) {
        case 1:
            return '<span class="label label-success radius">启用</span>';
        case 2:
            return '<span class="label label-danger radius">停用</span>';
    }
};
/*客户信息格式化----结束*/


/*公众号信息格式化----开始*/
//刷号类型
const mediumBrushTypeData = [{text:"未刷号", selected:true}, {text:"刷号"}, {text:"小半刷"}, {text:"大半刷"}];
const mediumBrushTypeDataAll = [{text:"全部", selected:true}, {text:"未刷号"}, {text:"刷号"}, {text:"小半刷"}, {text:"大半刷"}];

//公众号名称
const mediumNameFormatter = function (value, row) {
    if (row.difDays <= 3) {
        return '<span class="label badge-success radius name_title">新</span>'+ value;
    } else {
        return value;
    }
};

//公众号类型
const mediumTypeFormatter = function (value) {
    switch (value) {
        case 1:
            return '<span class="label label-warning radius">公众号</span>';
        case 2:
            return '<span class="label label-success radius">视频号</span>';
        case 3:
            return '<span class="label label-primary radius">抖音号</span>';
        case 4:
            return '<span class="label label-secondary radius">快手号</span>';
    }
};

//男女粉比例
const mediumSexRatioFormatter = function (value, row) {
    const manRatio = row.manRatio;
    const woman_ratio = 100 - Number(manRatio);
    return "<span style='color: blue'>"+ manRatio +"</span>/<span style='color: magenta'>"+ woman_ratio +"</span>";
};

//头条执行价
const mediumheadLineQuotedFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumQuoted('+ row.id +',1)">'+ value +'</a>'
};

//次条执行价
const mediumsecondLineQuotedFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumQuoted('+ row.id +',2)">'+ value +'</a>'
};

//三条执行价
const mediumThirdLineQuotedFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumQuoted('+ row.id +',3)">'+ value +'</a>'
};

//尾条执行价
const mediumTailLineQuotedFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumQuoted('+ row.id +',4)">'+ value +'</a>'
};

//头条成本价
const mediumHeadLineCostFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumCost('+ row.id +',1)">'+ value +'</a>'
};

//次条成本价
const mediumSecondLineCostFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumCost('+ row.id +',2)">'+ value +'</a>'
};

//三条成本价
const mediumThirdLineCostFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumCost('+ row.id +',3)">'+ value +'</a>'
};

//尾条成本价
const mediumTailLineCostFormatter = function (value, row) {
    return '<a title="查看价格曲线" style="color: #00a0e9" onclick="showMediumCost('+ row.id +',4)">'+ value +'</a>'
};

//发票税点
const mediumBillPointFormatter = function (value, row) {
    if (value < 0) {
        return '<span class="label label-success radius">普</span>' + (0-value) + '%';
    } else if (value === 0) {
        return '<span class="label label-default radius">不含票</span>';
    } else {
        return '<span class="label label-danger radius">专</span>' + value + '%';
    }
};

//是否刷号
const mediumIsBrushFormatter = function (value) {
    switch (value){
        case "刷号":
            return '<span class="label label-secondary radius" style="background-color: #FF5656">刷&nbsp;&nbsp;&nbsp;&nbsp;号</span>';
        case "小半刷":
            return '<span class="label label-warning radius" style="background-color: #FFAAAA">小半刷</span>';
        case "大半刷":
            return '<span class="label label-danger radius" style="background-color: #BF0000">大半刷</span>';
    }
};

const mediumVoucherCountFormatter = function (value, row) {
    if (value === 0) {
        return '<span class="label label-default radius">未上传</span>';
    } else {
        return '<span class="label label-success radius" onclick="showMediumVoucher('+ row.id +')">'+ value +'张</span>';
    }
};

//公众号更新时间
const mediumUpdateDateFormatter = function (value) {
    return dates("Y-m-d H:i:s", value);
};

//公众号状态
const mediumStatusFormatter = function (value) {
    switch (value){
        case 0:
            return '<span class="label label-default radius">已删除</span>';
        case 1:
            return '<span class="label label-success radius">启用</span>';
        case 2:
            return '<span class="label label-danger radius">停用</span>';
    }
};

//创建备注
const mediumCreateDescFormatter = function (value) {
    return value ? '<span data-toggle="tooltip" data-placement="bottom" title="'+value+'">'+value+'</span>' : '';
};

//查看公众号执行价曲线
const showMediumQuoted = function (medium_id, type) {
    openHtml(false, 9999, 9999, '<div id="echartsMain" style="width: 100%; height: 450px"></div>', function () {
        ajaxGetFun("order/listOrderQuotedByMediumId", {medium_id: medium_id}, function (bizData) {
            echarts.init(document.getElementById("echartsMain")).setOption({
                title: bizData.title,
                tooltip: {},
                legend: {
                    data: ["头条执行价", "次条执行价", "三条执行价", "尾条执行价"],
                    selected: {"头条执行价": type === 1, "次条执行价": type === 2, "三条执行价": type === 3, "尾条执行价": type === 4}
                },
                xAxis: {
                    type: "time",
                    name: "投放日期"
                },
                yAxis: {
                    type: "value",
                    name: "价格（元）"
                },
                series: bizData.series,
            });
        }, null, "获取公众号执行价统计");
    }, function (index, layero) {
        layer.close(index);
    });
};

//查看公众号成本价曲线
const showMediumCost = function (medium_id, type) {
    openHtml(false, 9999, 9999, '<div id="echartsMain" style="width: 100%; height: 450px"></div>', function () {
        ajaxGetFun("order/listOrderCostByMediumId", {medium_id: medium_id}, function (bizData) {
            echarts.init(document.getElementById("echartsMain")).setOption({
                title: bizData.title,
                tooltip: {},
                legend: {
                    data: ["头条成本价", "次条成本价", "三条成本价", "尾条成本价"],
                    selected: {"头条成本价": type === 1, "次条成本价": type === 2, "三条成本价": type === 3, "尾条成本价": type === 4}
                },
                xAxis: {
                    type: "time",
                    name: "投放日期"
                },
                yAxis: {
                    type: "value",
                    name: "价格（元）"
                },
                series: bizData.series,
            });
        }, null, "获取公众号成本价统计");
    }, function (index, layero) {
        layer.close(index);
    });
};

//展示公众号图片
const showMediumVoucher = function (mediumId) {
    ajaxGetFun("medium/listVoucherByMediumId", {mediumId: mediumId}, function(bizData) {
        if (bizData == null || bizData.length === 0) {
            showWarnMsg("该公众号暂无图片文件");
        } else {
            showVoucher(bizData);
        }
    }, null, "获取公众号凭证");
};
/*公众号信息格式化----结束*/

/*排期信息格式化----开始*/
//公众号投放位置
const mediumPutAddressData = [{text:"头条", selected:true}, {text:"二条"}, {text:"三条"}, {text:"四条"}, {text:"五条"}, {text:"六条"}, {text:"七条"}, {text:"尾条"}];
const mediumPutAddressDataAll = [{text:"全部", selected:true}, {text:"头条"}, {text:"二条"}, {text:"三条"}, {text:"四条"}, {text:"五条"}, {text:"六条"}, {text:"七条"}, {text:"尾条"}];
//视频号投放位置
const mediumVideoPutAddressData = [{text:"直发", selected:true}, {text:"链接"}, {text:"直发+链接"}, {text:"原创视频"}];
const mediumVideoPutAddressDataAll = [{text:"全部", selected:true}, {text:"直发"}, {text:"链接"}, {text:"直发+链接"}, {text:"原创视频"}];
//抖音号投放位置
const mediumDouyinPutAddressData = [{text:"抖音", selected:true}];
//快手号投放位置
const mediumKuaishouPutAddressData = [{text:"快手", selected:true}];
//排期投放位置
const orderPutAddressDataAll = [{text:"全部", selected:true}, {text:"头条"}, {text:"二条"}, {text:"三条"}, {text:"四条"}, {text:"五条"}, {text:"六条"}, {text:"七条"}, {text:"尾条"}, {text:"直发"}, {text:"链接"}, {text:"直发+链接"}, {text:"原创视频"}, {text:"抖音"}, {text:"快手"}];
//是否垫付
const orderIsAdvanceData = [{value:0, text:"否", selected:true}, {value:1, text:"是"}];
const orderIsAdvanceDataAll = [{value:"ALL", text:"全部", selected:true}, {value:0, text:"否"}, {value:1, text:"是"}];
//是否支付
const orderIsPaymentDataAll = [{value:"ALL", text:"全部", selected:true}, {value:0, text:"否"}, {value:1, text:"是"}];
//是否回款
const orderIsReceiptDataAll = [{value:"ALL", text:"全部", selected:true}, {value:0, text:"否"}, {value:1, text:"是"}];
//执行价
const orderQuotedPriceFormatter = function (value, row) {
    if (row.receiptRate < 100 && new Date().getTime() - 86400000 > row.putdate) {
        return '<span class="iconfont" style="color: red; font-size: 13px">&#xe684;</span><b style="color: #A60000">'+ value +'</b>';
    } else {
        return '<b style="color: #A60000">'+ value +'</b>';
    }
};
//成本价
const orderCostPriceFormatter = function (value, row) {
    if (row.paymentRate < 100 && new Date().getTime() + 86400000 > row.putdate) {
        return '<span class="iconfont" style="color: red; font-size: 13px">&#xe684;</span><b style="color: #1E9FFF">'+ value +'</b>';
    } else {
        return '<b style="color: #1E9FFF">'+ value +'</b>';
    }
};
//利润率
const orderProfitRateFormatter = function (value) {
    return value + "%";
};
//付款进度
const orderPaymentRateFormatter = function (value, row) {
    if (row.costPrice <= 0) {
        return '无成本';
    } else if (value >= 100) {
        return '<span class="label label-success radius" onclick="showOrderPaymentVoucher('+ row.id +')">'+ value +'%</span>';
    } else if (value <= 0) {
        return '<span class="label label-danger radius">0%</span>';
    } else {
        return '<span class="label label-danger radius" onclick="showOrderPaymentVoucher('+ row.id +')">'+ value +'%</span>';
    }
};
//回款进度
const orderReceiptRateFormatter = function (value, row) {
    if (row.quotedPrice <= 0) {
        return '无报价';
    } else if (value >= 100) {
        return '<span class="label label-success radius" onclick="showOrderReceiptVoucher('+ row.id +')">'+ value +'%</span>';
    } else if (value <= 0) {
        return '<span class="label label-danger radius">0%</span>';
    } else {
        return '<span class="label label-danger radius" onclick="showOrderReceiptVoucher('+ row.id +')">'+ value +'%</span>';
    }
};
//是否垫付
const orderIsAdvanceFormatter = function (value) {
    return value === 1 ? "是" : "否";
};
//展示排期付款凭证
const showOrderPaymentVoucher = function (order_id) {
    var successFun = function(bizData) {
        if (bizData == null || bizData.length === 0) {
            showWarnMsg("该排期暂无付款凭证");
        } else {
            showVoucher(bizData);
        }
    };
    ajaxPostFun("payment/getVouchersByOrderId", {order_id: order_id}, successFun, null, "获取排期付款凭证");
};
//展示排期回款凭证
const showOrderReceiptVoucher = function (order_id) {
    var successFun = function(bizData) {
        if (bizData == null || bizData.length === 0) {
            showWarnMsg("该排期暂无付款凭证");
        } else {
            showVoucher(bizData);
        }
    };
    ajaxPostFun("receipt/getVouchersByOrderId", {order_id: order_id}, successFun, null, "获取排期回款凭证");
};
/*档期信息格式化----结束*/

/*排期修改申请信息格式化----开始*/
//状态
const order_edit_status_data_all = [{value:-1, text:"全部", selected:true}, {value:1, text:"待审核"}, {value:2, text:"审核不通过"}, {value:3, text:"审核通过"}];
//排期修改申请状态
const order_edit_status_formatter = function (value, row) {
    switch (value) {
        case 0:
            return '<span class="label label-default radius">已删除</span>';
        case 1:
            return '<span class="label label-primary radius">待审核</span>';
        case 2:
            return '<span class="label label-default radius" data-toggle="tooltip" data-placement="bottom" title="'+row.auditDesc+'">审核不通过</span>';
        case 3:
            return '<span class="label label-secondary radius">审核通过</span>';
    }
};
/*排期修改申请信息格式化----结束*/

/*付款记录信息格式化----开始*/
//状态
const paymentStatusDataAll = [{value:"ALL", text:"全部", selected:true}, {value:1, text:"待审核"}, {value:2, text:"审核不通过"}, {value:3, text:"待支付"}, {value:4, text:"已支付"}];
//付款编号
const paymentIdFormatter = function (value, row) {
    if (row.voucherCount === 0) {
        return value;
    } else {
        return '<a title="查看凭证" style="color: #00a0e9" onclick="showPaymentVoucher('+ value +')">'+ value +'</a>'
    }
};
//付款金额
const paymentPayMoneyFormatter = function (value) {
    return '<b style="color: #00ee00">'+ value +'</b>';
};
//申请时间
const payment_create_date_formatter = function (value) {
    return dates("Y-m-d H:i:s", value);
};
//申请事由
const payment_create_desc_formatter = function (value) {
    return value ? '<span data-toggle="tooltip" data-placement="bottom" title="'+value+'">'+value+'</span>' : '';
};
//审核时间
const payment_audit_date_formatter = function (value) {
    if (value) {
        return dates("Y-m-d H:i:s", value);
    }
};
//支付时间
const payment_pay_date_formatter = function (value) {
    if (value) {
        return dates("Y-m-d H:i:s", value);
    }
};
//支付备注
const payment_pay_desc_formatter = function (value) {
    return value ? '<span data-toggle="tooltip" data-placement="bottom" title="'+value+'">'+value+'</span>' : '';
};
//状态
const paymentStatusFormatter = function (value, row) {
    switch (value) {
        case 1:
            return '<span class="label label-primary radius">待审核</span>';
        case 2:
            return '<span class="label label-default radius" data-toggle="tooltip" data-placement="bottom" title="'+row.auditDesc+'">不通过</span>';
        case 3:
            return '<span class="label label-secondary radius">待支付</span>';
        case 4:
            return '<span class="label label-success radius">已支付</span>';
    }
};
//是否开票
const payment_is_invoice_formatter = function (value) {
    switch (value) {
        case 0:
            return '<span class="label label-primary radius">未开票</span>';
        case 1:
            return '<span class="label label-success radius">已开票</span>';
        case 2:
            return '<span class="label label-default radius">不开票</span>';
    }
};
//展示付款凭证
const showPaymentVoucher = function (paymentId) {
    ajaxGetFun("payment/listPaymentVoucherByPaymentId", {paymentId: paymentId}, function(bizData) {
        if (bizData == null || bizData.length === 0) {
            showWarnMsg("该付款记录暂无凭证");
        } else {
            showVoucher(bizData);
        }
    }, null, "获取付款凭证");
};
/*付款记录信息格式化----结束*/


/*回款记录信息格式化----开始*/
//状态
const receiptStatusDataAll = [{value:"ALL", text:"全部", selected:true}, {value:1, text:"待审核"}, {value:2, text:"审核不通过"}, {value:3, text:"回款完成"}];
//回款编号
const receiptIdFormatter = function (value, row) {
    if (row.voucherCount === 0) {
        return value;
    } else {
        return '<a title="查看凭证" style="color: #00a0e9" onclick="showReceiptVoucher('+ value +')">'+ value +'</a>'
    }
};
//回款金额
const receiptRecMoneyFormatter = function (value) {
    return '<b style="color: #c94d31">'+ value +'</b>';
};
//状态
const receiptStatusFormatter = function (value, row) {
    switch (value) {
        case 1:
            return '<span class="label label-primary radius">待审核</span>';
        case 2:
            return '<span class="label label-default radius" data-toggle="tooltip" data-placement="bottom" title="'+row.auditDesc+'">审核不通过</span>';
        case 3:
            return '<span class="label label-success radius">回款完成</span>';
    }
};
//展示回款凭证
const showReceiptVoucher = function (receiptId) {
    ajaxGetFun("receipt/listReceiptVoucherByReceiptId", {receiptId: receiptId}, function(bizData) {
        if (bizData == null || bizData.length === 0) {
            showWarnMsg("该付款记录暂无凭证");
        } else {
            showVoucher(bizData);
        }
    }, null, "获取回款凭证");
};
/*回款记录信息格式化----结束*/